package com.cedric.yixianpai.game.cards.Sects.swordCards.d_YuanYing;

import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JuLingXinFa extends SwordCard {
    private int n = 0;//每回合加n层聚灵心法标志，每有2层回合开始前加1灵气

    /**
     * title:聚灵心法
     * effect:SE+1/1/3 每2/1/1回合加1灵气
     */
    public JuLingXinFa(@Value("1") int lvl) {
        super("聚灵心法");
        this.setLevel(lvl);
        this.setPeriod(Period.YUANYING);
        this.setDescription("灵气+1/1/3 每2/1/1回合加1灵气");

        this.setSustained();
        if (1 == lvl) {
            this.setSpiritAdd(1);
            this.n = 1;
        } else if (2 == lvl) {
            this.setSpiritAdd(1);
            this.n = 2;
        } else if (3 == lvl) {
            this.setSpiritAdd(3);
            this.n = 2;
        } else {
            throw new RuntimeException("Card Level Error!");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        Sta1.getPlayerBuff().addSpiritualEnergy(this.getSpiritAdd());
        Sta1.getPlayerBuff().addAddJuLingXF(this.n);
        if (this.getLevel() == 1) {
            Sta1.getPlayerBuff().addJulingXinFa(1);//使用本张牌当作聚灵1回合
        }
        return true;
    }
}
